<?php
/**
 * @Author: Marte
 * @Date:   2020-03-28 15:40:46
 * @Last Modified by:   Marte
 * @Last Modified time: 2020-03-28 15:41:56
 */

if( ! function_exists('js_url')){
        function js_url($filename, $path='')
        {
                if( ! function_exists('base_url')){
                        $CI = & get_instance();
                        $CI->load->helper('url');
                }
                $file = ($path != '' ? $path : 'statics/js/').$filename.'.js';
                $uri = base_url($file);

                return $uri;
        }
}


if( ! function_exists('css_url')){
        function css_url($filename, $path='')
        {
                if( ! function_exists('base_url')){
                        $CI = & get_instance();
                        $CI->load->helper('url');
                }
                $file = ($path != '' ? $path : 'statics/css/').$filename.'.css';
                $uri = base_url($file);

                return $uri;
        }
}


if( ! function_exists('img_url')){
        function img_url($filename, $path='')
        {
                if( ! function_exists('base_url')){
                        $CI = & get_instance();
                        $CI->load->helper('url');
                }
                $file = ($path != '' ? $path : 'statics/images/').$filename;
                $uri = base_url($file);

                return $uri;
        }
}



echo js_url('jquery'); // http://a.b.com/statics/js/jquery.js
echo css_url('main'); // http://a.b.com/statics/css/main.css
echo img_url('img.png'); // http://a.b.com/statics/images/img. png

echo js_url('jquery', 'static2018/js'); // http://a.b.com/static2018/js/jquery.js
echo css_url('main', 'static2018/css'); // http://a.b.com/static2018/css/main.css
echo img_url('img.png', 'static2018/images'); // http://a.b.com/static2018/images/img. png
